<?php JHTML::_('behavior.formvalidation'); ?>
<?php $editor = JFactory::getEditor(); ?>
<style>
.ZebraDialog{
    top: 60px !important;
}
</style>


<form action="index.php?option=com_information" method="post" name="adminForm" class="adminform" enctype="multipart/form-data">
	
    <div class="div-information" >
    <?php
      //  echo "<pre>";
//                print_r($this->row);
//                echo "</pre>";
    ?>
      <table border=0 class="table-information">
            <tr>
                <td></td>
                <td class="err">※印は入力必須項目です。</td>
            </tr>
                
            <tr>
                <td class="text_right">
                    インフォメーションカテゴリ名
                </td>
                
                <td >
                    <?php
                    $cid = JRequest::getVar('cid');
                    if (!empty($cid ))
                    {
                    ?>
                    <span id="select_cain">
                    <select id="listcain" name="listcain" class="medium" >
                    	<?php
                            foreach($this->listcain as $value){
                          ?>
                          <option value="<?php echo $value->CAIN_CODE; ?>"<?php if($value->CAIN_CODE == $this->row->INFO_CAIN_CODE) echo ' selected ';?> >
                          <?php echo $value->CAIN_NAME; ?></option>
                          <?php
                            }
                          ?>
                    </select>
                    </span>
                    <?php
                    }
                    else if (empty($cid ))
                    {
                    
                    ?>
                    <span id="select_cain">
                    <select id="listcain" name="listcain" class="medium">
                    	<?php
                            foreach($this->listcain as $value){
                          ?>
                          <option value="<?php echo $value->CAIN_CODE; ?>">
                          <?php echo $value->CAIN_NAME; ?></option>
                          <?php
                            }
                          ?>
                    </select>
                    </span>
                   <?php } ?>
                   <input style="text-align: left;" type="button" name="btnCREATE_CADM" id="btnCREATE_CADM" value="カテゴリ作成" class="button" />
                </td>  
            </tr>
            <tr>
                <td class="text_right">
                    配信先<span class="err">※</span>
                </td>
                    <td><textarea id="jformMAIL_USER" name="jform[MAIL_USER]" cols="44" rows="6"><?php $cid = JRequest::getVar('cid');if (!empty($cid)){foreach($this->rowuser as $valueuser){echo ($valueuser->name.'('.$valueuser->USIN_USER_CODE.');');}}else {echo $this->row->MAIL_USER;}?></textarea>     
                    <input id="btnSERQ_SEND_USER_ID_LIST" name="btnSERQ_SEND_USER_ID_LIST"  type="button" style="vertical-align: top;" value="配信先追加"/>
                    <input id="btninfo_clear" type="button" value="クリア" style="vertical-align: top;" onclick="document.id('jformMAIL_USER').value='';" />
                    </td>
                    
               </tr>
            <tr>
                <td class="text_right">
                    件名<span class="err">※</span>
                </td>
                <td >
                    <input type="text" name="info_subject" id="info_subject" class="input_bigx" size="30" value="<?php echo $this->row->INFO_TITLE?>" />
                </td>  
            </tr>
            <tr>
            	<td class="text_right">インフォメーション本文<span class="err">※</span></td>
                <td><textarea cols="90" rows="15"  id="info_body" name="info_body" ><?php echo $this->row->INFO_BODY?></textarea></td>
            </tr>
            <tr >
                <td style="height:10px;"></td>
                <td style="height:10px;"></td>
            </tr>
            <tr>
            	<td class="text_right">ファイル検索 1 </td>
            	<td>
                    <?php HelperBG::getLibUploadify(); ?>

                    <?php HelperBG::getUpload('info_attach1', $this->row->INFO_FILE_1, 'uploads/files/com_information'); ?>
                </td>
            </tr>
                        
            <tr>
            	<td class="text_right">ファイル検索 2 </td>
            	<td>
                    <?php HelperBG::getUpload('info_attach2', $this->row->INFO_FILE_2, 'uploads/files/com_information'); ?>
                </td>
            </tr> 
            <tr>
            	<td class="text_right">ファイル検索 3 </td>
            	<td>
                    <?php HelperBG::getUpload('info_attach3', $this->row->INFO_FILE_3, 'uploads/files/com_information'); ?>
                </td>
            </tr>      
            <tr>
            	<td class="text_right">ファイル検索 4 </td>
            	<td>
                    <?php HelperBG::getUpload('info_attach4', $this->row->INFO_FILE_4, 'uploads/files/com_information'); ?>
                </td>
            </tr>
            <tr>
            	<td class="text_right">ファイル検索 5 </td>
            	<td>
                    <?php HelperBG::getUpload('info_attach5', $this->row->INFO_FILE_5, 'uploads/files/com_information'); ?>
                </td>
            </tr>
            
            <tr>
                <td>
                    <input type="text" style="display: none;"  name="input_id" id="input_id" value="<?php echo $this->row->INFO_CODE?>" />
                </td>
            </tr>
      </table><br/>
      <div>
        <input type="hidden" name="task" value="" />
      </div>
</form>
<script>     
     var zb;
        //show a dialog box: COCH search
        jq('#btnCREATE_CADM').bind('click', function(e) {
            e.preventDefault();
            zb = new jq.Zebra_Dialog('', {
                source:  {'ajax': 'index.php?option=com_information&views=bg&task=popup_cadm&tmpl=component'},
                height: 800,
                width: 600,
                title:  '',
                type:  '',
                buttons:  [
                    {caption: '閉じる', callback: function() { }}
                        
                ],
                onClose: function(caption){
                    //ajax load cadm
                        var cain_current = jq("#listcain").val();
                    	var url = "index.php?option=com_information&task=loadCain&cain_current="+cain_current;
                        
                        jq.get(url, function(data) {
                          jq('#select_cain').html(data);
                        });
                        
                }
                               
            });
        }); 
</script>
<script>
    jq(document).ready(function() {

        // show a dialog box when clicking on a link
        jq('#btnSERQ_SEND_USER_ID_LIST').bind('click', function(e) {
            e.preventDefault();
            jq.Zebra_Dialog('', {
                source:  {'ajax': 'index.php?option=com_information&view=bg&task=popup&tmpl=component'},
                /*source: {'iframe': {
                    
                    'src':  'index.php?option=com_popup&view=bg&task=popup&tmpl=component',
                    'height': 450
                }},*/
                height: 750,
                width: 850,
                title:  '配信先選択',
                type:  '',
                buttons:  [
                    {caption: 'キャンセル', callback: function() {}},
                    {caption: 'OK', callback: function() {
                        jq('#jformMAIL_USER').val(jq('#jformMAIL_USER').val()+jq('#list_uid').val());
                    }
                        
                    }
                ]
            });
        });   
                        
     });
</script>